<template>
  <header class="tt-header">
    <div class="tt-header-box">
      <div class="logo">
        <span class="icon"></span>
      </div>
      <div class="search">
        <span class="icon bi bi-search"></span>
        <input 
          type="text" 
          placeholder="搜索"
          @focus="jumpTo"
           />
      </div>
    </div>
  </header>
</template>
<style lang="less">
@import "../../assets/less/variable.less";
.tt-header {
  width: 100%;
  height: @headerHeight;
  border-bottom: 1px solid @borderColor1;
  background-color: rgba(255, 255, 255, 1);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  .tt-header-box {
    height: @headerHeight;
    padding-left: @padding2;
    padding-right: @padding2;
    display: flex;
    .logo {
      width: 60px;
      height: @headerHeight;
      // background-color: red;
      .icon {
        display: block;
        width: 30px;
        height: 30px;
        background-image: url("../../assets/logo.png");
        background-size: cover;
        margin: (@headerHeight - 30)/2 auto;
      }
    }
    .search {
      flex-grow: 1;
      height: @headerHeight;
      //    background-color: green;
      position: relative;
      overflow: hidden;
      .icon {
        //    行内元素 inline ,加了浮动和绝对/固定定位，具有块特性
        position: absolute;
        left: (36px - 18) / 2;
        top: (@headerHeight - 18) / 2;
        width: 18px;
        height: 18px;
        // background-color: blue;
        font-size: 14px;
        text-align: center;
      }
      input {
        display: block;
        width: 100%;
        height: 30px;
        border-radius: (30px / 2);
        margin-top: (@headerHeight - 30) / 2;
        margin-bottom: (@headerHeight - 30) / 2;
        padding-left: 30px;
        font-size: 18px;
        border: 1px solid #ccc;
      }
      input:focus {
        border: 1px solid @borderColor1;
      }
    }
  }
}
</style>

<script>
export default {
   methods: {
     jumpTo(){
        // 路由跳转 切换搜索页面
        this.$router.push({path:'/search'})
     }
   }
}
</script>